
from setting import suite
from loguru import logger
import unittest
import os

# 选择测试套件
def select_case_level(lst):

    # 判断lst是否是列表，直接返回报错
    if not isinstance(lst,list):
        logger.error("传递的数据类型为:{}".format(type(lst)))
        return '要求传递的数据类型为列表'

    # 循环此列表，然后依次读取元素加入到套件中
    cases_suite = []
    for x in lst:
        suite = unittest.TestLoader().discover('cases', 'test*{}.py'.format(x))
        cases_suite.extend(suite)
    return cases_suite


# 返回项目路径
def get_project_path():
    current_path = os.path.abspath(__file__)        # __file__ 代表当前文件
    return current_path.split('utils')[0]

# 获取日志路径
def get_log(filename):
    log_path = os.path.join(get_project_path(),'logs')
    return os.path.join(log_path,filename)




if __name__ == '__main__':
    print(get_log('litemall.log'))

